package socket;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Class description here
 * Created at 2015/5/26 22:21
 *
 * @author young
 * @version 1.0.0
 */
public class InitSocket {
	public static Socket socket;
	public static InputStream is;
	public static OutputStream os;
	public static Map<String, Boolean> map = new ConcurrentHashMap<>();

	public static void init(String url, int port){
		try {
			socket = new Socket(url, port);
			is = socket.getInputStream();
			os = socket.getOutputStream();
			map.put("done", true);
		} catch (Exception e) {
			try {
				if(null!=os) os.close();
				if(null!=is) is.close();
				if(null!=socket) socket.close();
				socket = null;
				e.printStackTrace();
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}
	}
}
